<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      class="m-r-10"
      routerLink="/aisi-recyc/love-luckdraw-edit"
      [queryParams]="{type: 0}"
    >新增活动</button>

    <button
      nz-button
      nzType="primary"
      routerLink="/aisi-recyc/love-luckdraw-record"
    >下单抽奖记录</button>
  </div>
  
  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="100px" nzLeft>ID</th>
          <th nzAlign="center" nzWidth="180px">活动名称</th>
          <th nzAlign="center" nzWidth="120px">状态</th>
          <th nzAlign="center" nzWidth="120px">抽奖限制</th>
          <th nzAlign="center" nzWidth="120px">每日发放总数</th>
          <th nzAlign="center" nzWidth="120px">当日剩余总数</th>
          <th nzAlign="center" nzWidth="170px">开始时间</th>
          <th nzAlign="center" nzWidth="170px">结束时间</th>
          <th nzAlign="center" nzWidth="170px">更新时间</th>
          <th nzAlign="center" nzWidth="250px">备注</th>
          <th nzAlign="center" nzWidth="280px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center" nzLeft>{{ data.id }}</td>
          <!-- 活动名称 -->
          <td nzAlign="center">{{ data.activityName }}</td>
          <!-- 状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.status | loveLuckDrawStatus: 'color'}">
              {{ data.status | loveLuckDrawStatus: 'label' }}
            </span>
          </td>
          <!-- 抽奖限制 -->
          <td nzAlign="center">
            {{ data.raffleLimit === 0 ? '需登录' : (data.raffleLimit === 1 ? '无需登录' : '-') }}
          </td>
          <!-- 每日发放总数 -->
          <td nzAlign="center">{{ data.total || '0' }}</td>
          <!-- 当日剩余总数 -->
          <td nzAlign="center">{{ data.surplusTotal || '0' }}</td>
          <!-- 开始时间 -->
          <td nzAlign="center">{{ data.beginTime || '-' }}</td>
          <!-- 结束时间 -->
          <td nzAlign="center">{{ data.endTime || '-' }}</td>
          <!-- 更新时间 -->
          <td nzAlign="center">{{ data.updateTime || '-' }}</td>
          <!-- 备注 -->
          <td nzAlign="center">{{ data.bak || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <a
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-luckdraw-edit"
              [queryParams]="{type: 2, id: data.id}"
            >复制</a>

            <a
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-luckdraw-record"
              [queryParams]="{activityName: data.activityName}"
            >查看抽奖记录</a>

            <a
              nz-button
              nzType="link"
              nzSize="small"
              routerLink="/aisi-recyc/love-luckdraw-edit"
              [queryParams]="{type: 1, id: data.id}"
            >编辑</a>

            <a
              [ngStyle]="{'color': data.status === 4 ? '#67C23A' : '#F56C6C'}"
              nz-button
              nzType="link"
              nzSize="small"
              nz-popconfirm
              [nzPopconfirmTitle]="'确认' + (data.status === 4 ? '启用' : '禁用') + '?'"
              (nzOnConfirm)="changeStatus(data)"
            >{{ data.status === 4 ? '启用' : '禁用' }}</a>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>
